Repository navigation
feat: dsh web-profile settings entry opening the bili Web UI (#1590) - #1619
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1749-pr.1619.0609fb7This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1619.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成(按 ework-agent-pr 规则:不重做,拉分支核对代码 + CI)。过程中在 PR 分支上直接修了两个小问题(各一个独立标注 commit,已 push),详见下文。 ① 原 issue 方向(#1590)方向成立且与 owner 确认一致:#1590 floor 4「确认」拍板的方案(web-profile only、origin = ② 回归审查(触碰路径的既有行为清点)
③ 代码审查——发现并已直接修复的两个问题
接受的非阻塞边缘(不拦):shim 每次 launch rm-rf 重写,若用户手动往 安全面:client 端 origin 来自服务端 index 注入(非浏览器输入),无 XSS 面; ④ 测试有效性新测试有牙:tsup wrapper 形状(loader id、factory 仅 require react)、shim 布局 + symlink realpath、resolution 探针的三级 fallback 阶梯(bare → stale-shim file:// → no-shim file://)、patch 内容、NODE_PATH 前缀——这个 feature 回归时抓得住。我补的版本 stamp 测试钉住 ③.1。 ⑤ diff 整洁度8 文件全部与 dsh lane 目的相关,无空行/重排噪音、无锁文件连带、无跑题文件。我的两个 commit 均为小而有标注的追加。 结论
等 中文一句话:审了 PR #1619(dsh web 设置页 bili 设置入口)——方向与 #1590 owner 确认一致、对既有行为无回归(仅 dsh lane 增量,压缩路径字节级未动);直接在 PR 分支修了两个小问题(shim 版本号 off-by-one 恒写 0.0.0、tmpdir 在仓库内时测试因 tsx self-name 解析不确定),CI 全绿后可合并。 |
Adds a browser-side dsh client bundle (dsh.client platform:web) that
registers a "settings.section" page (id bili, order 100) in the dsh
web profile's settings nav. The host half injects globalThis.__BILI__
{origin} via webserver/index-inject when the proxy origin is known at
startup (attach mode binds register.base synchronously; spawn mode
degrades until the proxy is up). The entry opens <origin>/__bili/ in a
new tab, or shows an honest degraded hint when the origin is unknown.
Overlay-lane patch entries now use the bare specifier
"billion-context/dsh" when resolvable from the dsh tree (the scanner
anchors its require.resolve there too); the file:// URL remains the
fallback. NODE_PATH is prepended for the dsh child so split-prefix
installs still resolve. New exports: ./client and ./dsh/package.json.
writeDshClientShim read the version from path.dirname(path.dirname(hostBundle)) — but selfDistFile() is <root>/dist/<name>, so that arithmetic lands on <root>/dist, whose package.json does not exist; the catch swallowed it and every shim was stamped 0.0.0. Read from selfPackageRoot() directly, and pin the behavior with a regression test (skips when no dist build is present).
…r is inside a checkout (#1590) The existing guard package.json sat under home/dshhost/, which is NOT on the overlay probe anchor's walk-up chain. When os.tmpdir() lives inside a billion-context checkout (this sandbox), tsx's resolver matches the checkout's own self-named package.json before walking node_modules, so dshPluginEntry probed the checkout instead of the fixture shim and the bare-entry assertion failed on built trees. Move the guard to the home root so the nearest enclosing package.json can never be billion-context from either anchor.
937269f to
1b73937
Compare
… for both lanes (#1590) dsh's client-module scanner (dsh-client-modules, CLI 0.1.5-rc.x and desktop 0.2.0-rc.2 alike) requires an entry NAME to be a package-root specifier: exactPackageSpecifier returns undefined for any non-scoped specifier containing '/', so the graph row is silently dropped and the browser half never loads. The host half was unaffected (loader import resolves subpaths fine), which is why the injection worked while the settings entry never appeared. - launcher --patch entry + shim: bare 'billion-context'; shim exports gain '.' (root import = host half). dshPluginEntry now probes that the ROOT specifier resolves to a file ending agent/dsh-native.js — a foreign or stale install whose '.' points elsewhere degrades to the legacy file URL instead of importing the wrong module into dsh. - market-install lane: dsh.bundle.patch.yml name -> bare root, and the package exports['.'] moves from the CLI entry to the dsh host half (the dsh loader imports the bare root). opencode is unaffected either way: 1.18.x resolvePackageEntrypoint only reads exports['./server'] when the exports map is a record, and 2.x Host.resolve tries ['server',''] in order — the root is never reached while ./server exists. - browser bundle banner id matches the graph row id (package name). - tests: launcher fixtures + negative case (shim '.' -> other file falls back to file URL), settings-ui registration id, index-entry-guard pins exports['.'] to the dsh host half and its import inertness.
|
Rebased onto current master and fixed a real defect found while verifying locally: the browser half never actually loaded on the dsh versions tested (CLI Root causedsh's client-module scanner ( function exactPackageSpecifier(spec) { if (spec.startsWith("@")) ...; const i = spec.indexOf("/"); if (i === -1) return spec; /* subpath */ return void 0; }
// locatePkgJson: if (!pathLike && expectedPackageName === void 0) return void 0;
Fix (937269f → 3e838ab)
opencode is unaffected by the root-export change: 1.18.x Verification (real systems, both platforms)Linux CLI (dsh Windows desktop app (
Gates on the rebased head: typecheck ✓ · launcher + dsh-settings-ui + index-entry-guard + plugin-install-opencode 266/266 ✓ · build ✓. |
Closes #1590
给 dsh 的 web 配置文件页增加一个「bili设置」入口,跳转到 bili Web UI(与已有的 /acp 链接互补)。中文说明见 #1590。
What changed
src/agent/dsh-native.ts): onwebserver/index-inject(web-profile hosts only), pushes{kind:"global", name:"__BILI__", value:{origin}}into the index table. Origin =register.base(attach mode binds it synchronously; spawn mode binds it after bootstrap) falling back to theBILLION_CONTEXT_PROXYenv var — published only while known, so at startup-time collection the entry degrades to a hint instead of a stale link.src/agent/dsh-native-client.ts, new tsup entry →dist/agent/dsh-native-client.js): registers asettings.sectionslot (idbili, order 100, zh/en, label「bili设置」) that opens${origin}/__bili/in a new tab; shows a degraded hint whenglobalThis.__BILI__?.originis absent ("run /acp first, or launch through bili dsh").src/launcher.ts): the dsh client-module scanner resolves plugin packages byrequire.resolvewalk-up from the profile dir and silently skips whatever fails to resolve (catch→null ⇒ no graph row ⇒ the browser half never attached for the legacyfile://patch entry). Fixed at the source: everybili dshlaunch now writes a small resolvable package<DSH_HOME>/node_modules/billion-context(package.json exporting./dsh,./dsh/package.json,./client, plus symlinks into bili's live dist bundles — self-healing across auto-updates, no second code copy), anddshPluginEntry()probes resolution from DSH_HOME before writing the patch file: bare namebillion-context/dshwhen resolvable, legacy file:// URL fallback when the shim is broken/missing.NODE_PATHnow unconditionally prepends the base DSH_HOME's node_modules for all dsh lanes.Behavior flags (old → new)
bili dshnow creates<DSH_HOME>/node_modules/billion-context/(+ overlay-home copy) on every launch — no such directory existed before. Symlinked into bili's own dist and refreshed each launch (no drift).file:///…/dist/agent/dsh-native.js; now barebillion-context/dshwhenever resolvable from DSH_HOME (file-URL fallback retained for broken shims).<base DSH_HOME>/node_modulesfor every dsh lane (persistent + overlay)."./client"+"./dsh/package.json"and"dsh.client"platform metadata — npm package metadata consumed by the dsh scanner, NOT the user config surface:~/.config/billion-context/config.json,BILI_*env vars, and CLI flags are all unchanged.Pre-flight
bili dsh web --no-open): proxy origin injected into index.html asglobalThis.__BILI__; scanner graph row/plugins/billion-context/dsh/client.js?rev=…present and serving the client bundle (HTTP 200); shims self-healed in both base and overlay homes;.bili-acp.patch.ymlcarries the bare entry.E2E_CHECK=1) passes; the full run could not complete locally because the local model upstream documented intests/e2e/README.mdis down in this environment (unreachable, no local model service available). The diff is additive to the dsh lane only (launcher dsh branch, newsrc/agent/dsh-native*files, package metadata) — codex/Responses pipeline code paths are byte-identical — and CI (ci-e2e.yml) auto-runs e2e-codex on this PR since the diff touchessrc/agent/**.